package com.ing5.BL.android.cinece.util;


import org.apache.http.impl.client.DefaultHttpClient;

import android.content.Context;
import android.graphics.Bitmap;

import com.ing5.BL.android.cinece.api.client.AbstractRequest;

public class CacheClient {

    Context appContext;

    public CacheClient(Context appContext) {
        this.appContext = appContext;
    }

    
    public <T> T load(AbstractRequest<T> request) {

    	T result = null;
    	
        request.setCacheManager(new CacheManager(appContext));
        DefaultHttpClient client = new DefaultHttpClient();
        result = request.execute(client);
        
        return result;
    }

    public Bitmap loadImage(AbstractRequest<Bitmap> request) {

    	Bitmap result = null;
    	
        request.setCacheManager(new CacheManager(appContext));
        DefaultHttpClient client = new DefaultHttpClient();
        result = request.executeImage(client);
        
        return result;
    }
}
